﻿using System.Windows.Data;
using WeiboPlus.Common;
using WeiboPlus.Models;

namespace WeiboPlus.Converter
{
    public class ImageResolutionConverter : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var ir = value as ImageResolution;
            var desc = null as string;

            if (ir != null)
            {
                var str = "{0}x{1} {2}";
                var sufix = "";

                if (ir.Quality < 50)
                    sufix = AppResx.QualityLowText;
                else if (ir.Quality < 80)
                    sufix = AppResx.QualityMediumText;
                else
                    sufix = AppResx.QualityHighText;

                desc = string.Format(str, ir.Width, ir.Height, sufix);
            }

            return desc;
        }

        public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new System.NotImplementedException();
        }

        #endregion
    }
}
